;
$(function() {
    const $pop10 = $('.pop_window10');

    //请求用户数据
    let userInfo = {
        data: localStorage.getItem("userInfo"),
        getData() {
            let self = this
            Axios.post('user/user/userInfo.do',{}).then(res => {
                if (res.respCode === "S") {
                    localStorage.setItem("userInfo", JSON.stringify(res.data))
                    self.setInfo()
                    if (res.data.isOrderMan === 'TRUE') {
                        $('.member_buy').parent().show()
                    }
                    if (res.data.isShop === 'TRUE') {
                        $('.member_fresh').parent().show()
                    }
                }
            })
        },
        setInfo() {
            let self = this
            let userInfo = JSON.parse(localStorage.getItem('userInfo'))
            $('#portrait').attr('src', userInfo.headImage)
            $('.nickname').html(userInfo.nickname)
        }
    }

    userInfo.getData()

    let cartBadge = localStorage.getItem('cartBadge')
    if (cartBadge && cartBadge != 0) {
        $('.link-cartBadge').html(cartBadge)
        $('.link-cartBadge').css('display', 'block')
    }

    //footer
    $(".footer").delegate('ul', 'click', function() {
        var ix = $(this).index();
        switch (ix) {
            case 0:
                window.location.href = "../index.html";
                break;
            case 1:
                window.location.href = "../msg/msg.html";
                break;
            case 2:
                window.location.href = "../search/search.html";
                break;
            case 3:
                window.location.href = "../shopping/shopping.html";
                break;
            case 4:

        }

    });
    // $("body").delegate('a', 'click', function() {
    //     const hrefs = $(this).attr("href");
    //     if (hrefs == "#" || hrefs == "" || hrefs == undefined) {
    //         console.log($(this).attr("href"))
    //         pop_win10();
    //     }
    // });

    function pop_win10() {
        $pop10.show(function() {
            const this_ = $(this);
            setTimeout(function() {
                this_.hide();
            }, 800);
        });
    }
    $pop10.click(function() {
        $(this).hide();
    });

});
